<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head  th:include="inc/examHeader::header">
		</head>
<form id="userAnswer" method="post">
	<input type="text" readonly="readonly" style="display: none" name="spendTime" id="spendTime" />
	<div th:if="${chK.code=='单选题'}" style="display: none" th:each="chK,iterStat : ${chKs}" th:id="'dan'+${chK.orderCode}">
		<div class="paper-d-title" th:text="${chK.code}"></div>
		<div class="nottake-ba">
			<ul>
				<li>
					<div class="nottake-ba-title" th:text="'('+${chK.orderCode}+')、'+${chK.content}"></div>
					<div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.a)} ? 'none': 'block')} + ''">
					    	<a th:text="'A.'+${chK.a}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'1'"  value="A" style="display:none"/>
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.b)} ? 'none': 'block')} + ''">
					    	<a th:text="'B.'+${chK.b}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'2'"  value="B" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.c)} ? 'none': 'block')} + ''">
					    	<a th:text="'C.'+${chK.c}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'3'"  value="C" style="display:none" />
					    	<div class="documentation-check"></div> 
					    </div>					    
					     <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.d)} ? 'none': 'block')} + ''">
					    	<a th:text="'D.'+${chK.d}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'4'"  value="D" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.e)} ? 'none': 'block')} + ''">
					    	<a th:text="'E.'+${chK.e}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'5'"  value="E" style="display:none" />
					    	<div class="documentation-check"></div> 
					    </div>
				</li>
			</ul>
		</div>
	</div>
	<div  th:if="${chK.code=='多选题'}" style="display: none" th:each="chK,iterStat : ${chKs}" th:id="'duo'+${chK.orderCode}">
		<div class="paper-d-title" th:text="${chK.code}"></div>
		<div class="nottake-ba">
			<ul>
				<li>
					<div  class="nottake-ba-title" th:text="'('+${chK.orderCode}+')、'+${chK.content}"></div>
					<div class="take-eb">
						<div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.a)} ? 'none': 'block')} + ''">
					    	<a th:text="'A.'+${chK.a}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="A" style="display:none" />
					    	<div class="documentation-check" ></div>
					    </div>
					    <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.b)} ? 'none': 'block')} + ''">
					    	<a th:text="'B.'+${chK.b}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="B" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.c)} ? 'none': 'block')} + ''">
					    	<a th:text="'C.'+${chK.c}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="C" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>					    
					     <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.d)} ? 'none': 'block')} + ''">
					    	<a th:text="'D.'+${chK.d}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="D" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.e)} ? 'none': 'block')} + ''">
					    	<a th:text="'E.'+${chK.e}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="E" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					</div>
				</li>
			</ul>
		</div>
	</div>
	<div style="display: none" th:if="${chK.code=='判断题'}"
		th:each="chK,iterStat : ${chKs}" th:id="'pan'+${chK.orderCode}">
		<div class="paper-d-title" th:text="${chK.code}"></div>
		<div class="nottake-ba">
			<ul>
				<li>
					<div class="nottake-ba-title"
						th:text="'('+${chK.orderCode}+')、'+${chK.content}"></div>
					<div class="nottake-bb">
					    	A.正确
					    	<input th:name="${chK.id}" th:id="${chK.id}+'1'"  value="A" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb">					    	
					        B.错误
					        <input th:name="${chK.id}" th:id="${chK.id}+'2'"  value="B" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
				</li>
			</ul>
		</div>
	</div>
	<div style="display: none" th:if="${chK.code=='问答题'}"
		th:each="chK,iterStat : ${chKs}" th:id="'wen'+${chK.orderCode}">
		<div class="paper-d-title" th:text="${chK.code}"></div>
		<div class="nottake-ba">
			<ul>
				<li>
					<div class="nottake-ba-title"
						th:text="'('+${chK.orderCode}+')、'+${chK.content}"></div>
					 <div class="nottake-bd">
						    	<textarea class="nottake-textarea" th:name="${chK.id}"></textarea>
				     </div>
				</li>
			</ul>
		</div>
	</div>
	<div style="display: none" th:if="${chK.code=='填空题'}"
		th:each="chK,iterStat : ${chKs}" th:id="'tian'+${chK.orderCode}">
		<div class="paper-d-title" th:text="${chK.code}"></div>
		<div class="nottake-ba">
			<ul>
				<li>
					<div class="nottake-ba-title"
						th:text="'('+${chK.orderCode}+')、'+${chK.content}"></div>
					 <div class="nottake-bd">
						    	<textarea class="nottake-textarea" th:name="${chK.id}"></textarea>
				     </div>
				</li>
			</ul>
		</div>
	</div>
</form>
<div class="btn_manual">
	<img onclick="onthe()" id="syg" src="../images/btn_onthe.png" /><img
		onclick="next()" id="xyg" src="../images/btn_next.png" />
</div>
<script th:inline="javascript">  
/*<![CDATA[*/
    var  chks= [[${chKs}]];
    var chs=1;
    var paperId=[[${#httpServletRequest.getParameter('paperId')}]];
    if(chks.length>0){
    	   if(chks[0].code=="单选题"){
    	    	$("#dan"+chks[0].orderCode).css('display','block');
    	    }
    	    if(chks[0].code=="多选题"){
    	    	$("#duo"+chks[0].orderCode).css('display','block');
    	    }
    	    if(chks[0].code=="判断题"){
    	    	$("#pan"+chks[0].orderCode).css('display','block');
    	    }
    	    if(chks[0].code=="问答题"){
    	    	$("#wen"+chks[0].orderCode).css('display','block');
    	    }
    	    if(chks[0].code=="填空题"){
    	    	$("#tian"+chks[0].orderCode).css('display','block');
    	    }
    	  $("#syg").attr('style',"display: none");
    	  
    }   
    function next(){    	
    	   if(chks.length>0){   	
 	   if(chks[chs].code=="单选题"){
 		  if( $("#tian"+chks[chs-1].orderCode).text()!=""){
 			 $("#tian"+chks[chs-1].orderCode).css('display','none');
 		   }
 		if( $("#wen"+chks[chs-1].orderCode).text()!=""){
 			 $("#wen"+chks[chs-1].orderCode).css('display','none');
 		   }
 		if( $("#pan"+chks[chs-1].orderCode).text()!=""){
 			 $("#pan"+chks[chs-1].orderCode).css('display','none');
 		   }
 		if( $("#duo"+chks[chs-1].orderCode).text()!=""){
			 $("#duo"+chks[chs-1].orderCode).css('display','none');
		   }
 		    $("#dan"+chks[chs-1].orderCode).css('display','none');
	    	$("#dan"+chks[chs].orderCode).css('display','block');
	    	chs=chs+1;
	    }
 	   else if(chks[chs].code=="多选题"){
 		  if( $("#dan"+chks[chs-1].orderCode).text()!=""){
   			 $("#dan"+chks[chs-1].orderCode).css('display','none');
   		   }
 		 if( $("#tian"+chks[chs-1].orderCode).text()!=""){
			 $("#tian"+chks[chs-1].orderCode).css('display','none');
		   }
		if( $("#wen"+chks[chs-1].orderCode).text()!=""){
			 $("#wen"+chks[chs-1].orderCode).css('display','none');
		   }
		if( $("#pan"+chks[chs-1].orderCode).text()!=""){
			 $("#pan"+chks[chs-1].orderCode).css('display','none');
		   }
   	        $("#duo"+chks[chs-1].orderCode).css('display','none');
    	    $("#duo"+chks[chs].orderCode).css('display','block');
    	    chs=chs+1;
	    }
 	  else if(chks[chs].code=="判断题"){
 		 if( $("#duo"+chks[chs-1].orderCode).text()!=""){
  			 $("#duo"+chks[chs-1].orderCode).css('display','none');
  		   }
 		if( $("#dan"+chks[chs-1].orderCode).text()!=""){
			 $("#dan"+chks[chs-1].orderCode).css('display','none');
		   }
		if( $("#tian"+chks[chs-1].orderCode).text()!=""){
			 $("#tian"+chks[chs-1].orderCode).css('display','none');
		   }
		if( $("#wen"+chks[chs-1].orderCode).text()!=""){
			 $("#wen"+chks[chs-1].orderCode).css('display','none');
		   }
	 	    $("#pan"+chks[chs-1].orderCode).css('display','none');
	    	$("#pan"+chks[chs].orderCode).css('display','block');
	    	chs=chs+1;
	    }
 	  else if(chks[chs].code=="问答题"){
 		 if( $("#pan"+chks[chs-1].orderCode).text()!=""){
  			 $("#pan"+chks[chs-1].orderCode).css('display','none');
  		   }
 		if( $("#duo"+chks[chs-1].orderCode).text()!=""){
			 $("#duo"+chks[chs-1].orderCode).css('display','none');
		   }
		if( $("#dan"+chks[chs-1].orderCode).text()!=""){
			 $("#dan"+chks[chs-1].orderCode).css('display','none');
		   }
		if( $("#tian"+chks[chs-1].orderCode).text()!=""){
			 $("#tian"+chks[chs-1].orderCode).css('display','none');
		   }
	        $("#wen"+chks[chs-1].orderCode).css('display','none');
	    	$("#wen"+chks[chs].orderCode).css('display','block');
	    	chs=chs+1;
	    } 
 	 else if(chks[chs].code=="填空题"){
 		 if( $("#wen"+chks[chs-1].orderCode).text()!=""){
  			 $("#wen"+chks[chs-1].orderCode).css('display','none');
  		   }
 		if( $("#pan"+chks[chs-1].orderCode).text()!=""){
 			 $("#pan"+chks[chs-1].orderCode).css('display','none');
 		   }
 		if( $("#duo"+chks[chs-1].orderCode).text()!=""){
			 $("#duo"+chks[chs-1].orderCode).css('display','none');
		   }
 		if( $("#dan"+chks[chs-1].orderCode).text()!=""){
			 $("#dan"+chks[chs-1].orderCode).css('display','none');
		   }
	        $("#tian"+chks[chs-1].orderCode).css('display','none');
	    	$("#tian"+chks[chs].orderCode).css('display','block');
	    	chs=chs+1;
	    } 
 	    	 $("#syg").css('display','');
 	      if(chs==chks.length){
 	    	 $("#xyg").css('display','none');
 	    	 $("#submitExam").css('display',''); 
 	      }else{
 	    	 $("#xyg").css('display',''); 
 	      }
    	   
    	   }
    }
    function onthe(){
    	if(chks.length>0){
    	 if(chks[chs-2].code=="单选题"){
    		 if( $("#duo"+chks[chs-1].orderCode).text()!=""){
      			 $("#duo"+chks[chs-1].orderCode).css('display','none');
      		   }
    		 if( $("#pan"+chks[chs-1].orderCode).text()!=""){
      			 $("#pan"+chks[chs-1].orderCode).css('display','none');
      		   }  		
      		 if( $("#wen"+chks[chs-1].orderCode).text()!=""){
     			 $("#wen"+chks[chs-1].orderCode).css('display','none');
     		   }
      		if( $("#tian"+chks[chs-1].orderCode).text()!=""){
    			 $("#tian"+chks[chs-1].orderCode).css('display','none');
    		   }
  		    $("#dan"+chks[chs-1].orderCode).css('display','none');
 	    	$("#dan"+chks[chs-2].orderCode).css('display','block');
 	    	chs=chs-1;
 	    }
  	   else if(chks[chs-2].code=="多选题"){ 		 
  		   if( $("#pan"+chks[chs-1].orderCode).text()!=""){
  			 $("#pan"+chks[chs-1].orderCode).css('display','none');
  		   }  		
  		 if( $("#wen"+chks[chs-1].orderCode).text()!=""){
 			 $("#wen"+chks[chs-1].orderCode).css('display','none');
 		   }
  		if( $("#tian"+chks[chs-1].orderCode).text()!=""){
			 $("#tian"+chks[chs-1].orderCode).css('display','none');
		   }
  		 if( $("#dan"+chks[chs-1].orderCode).text()!=""){
 			 $("#dan"+chks[chs-1].orderCode).css('display','none');
 		   }
    	    $("#duo"+chks[chs-1].orderCode).css('display','none');
     	    $("#duo"+chks[chs-2].orderCode).css('display','block');
     	    chs=chs-1;
 	    }
  	  else if(chks[chs-2].code=="判断题"){
  		if( $("#wen"+chks[chs-1].orderCode).text()!=""){
 			 $("#wen"+chks[chs-1].orderCode).css('display','none');
 		   }
  		if( $("#tian"+chks[chs-1].orderCode).text()!=""){
			 $("#tian"+chks[chs-1].orderCode).css('display','none');
		   }
  		if( $("#duo"+chks[chs-1].orderCode).text()!=""){
 			 $("#duo"+chks[chs-1].orderCode).css('display','none');
 		   }
 		 if( $("#dan"+chks[chs-1].orderCode).text()!=""){
 			 $("#dan"+chks[chs-1].orderCode).css('display','none');
 		   }
 	 	    $("#pan"+chks[chs-1].orderCode).css('display','none');
 	    	$("#pan"+chks[chs-2].orderCode).css('display','block');
 	    	chs=chs-1;
 	    }
  	else if(chks[chs-2].code=="问答题"){
  		if( $("#tian"+chks[chs-1].orderCode).text()!=""){
 			 $("#tian"+chks[chs-1].orderCode).css('display','none');
 		   }
  		 if( $("#pan"+chks[chs-1].orderCode).text()!=""){
  			 $("#pan"+chks[chs-1].orderCode).css('display','none');
  		   }
  		 if( $("#duo"+chks[chs-1].orderCode).text()!=""){
  			 $("#duo"+chks[chs-1].orderCode).css('display','none');
  		   }
  		 if( $("#dan"+chks[chs-1].orderCode).text()!=""){
  			 $("#dan"+chks[chs-1].orderCode).css('display','none');
  		   }
 	 	    $("#wen"+chks[chs-1].orderCode).css('display','none');
 	    	$("#wen"+chks[chs-2].orderCode).css('display','block');
 	    	chs=chs-1;
 	    }
  	  else if(chks[chs-2].code=="填空题"){  		
  		if( $("#wen"+chks[chs-1].orderCode).text()!=""){
			 $("#wen"+chks[chs-1].orderCode).css('display','none');
		   }
  		 if( $("#pan"+chks[chs-1].orderCode).text()!=""){
  			 $("#pan"+chks[chs-1].orderCode).css('display','none');
  		   }
  		 if( $("#duo"+chks[chs-1].orderCode).text()!=""){
  			 $("#duo"+chks[chs-1].orderCode).css('display','none');
  		   }
  		 if( $("#dan"+chks[chs-1].orderCode).text()!=""){
  			 $("#dan"+chks[chs-1].orderCode).css('display','none');
  		   }
 	        $("#tian"+chks[chs-1].orderCode).css('display','none');
 	    	$("#tian"+chks[chs-2].orderCode).css('display','block');
 	    	chs=chs-1;
 	    }     	
    	   }
     $("#xyg").css('display','');
     if(chs==1){
     $("#syg").css('display','none');
     }else{
     $("#syg").css('display',''); 
     }
    }
   
    function saveAnswer(){
    	alert("正在提交，请稍后...");
    	$($(".nottake-bb")).each(function(){
    		if(!$(this).is(".active")){
		        $(this).children("input").remove();
    		}
    	});
    	$($(".nottake-bc")).each(function(){
    		if(!$(this).is(".active")){
		        $(this).children("input").remove();
    		}
    	});
    	$('#submitExam').attr('disabled','disabled');
    	clearInterval(settime);
    	var m1=parseInt(m)-parseInt($("#spendTime").val());  
    	totalSc=$("#totalSc").text();
    	$.ajax({
    		type:"POST",
    		data:$('#userAnswer').serialize(),
    		url:"/examReport/saveAnswer?paperId="+paperId+"&spendTime="+m1,
    		success:function(data){ 
    			 if($("#yc").html()==1){
						window.location.href="/examReport/afterExam"
					}else{
						 $.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">您已提交试卷，即将为您跳转到答案解析页面</div></div>', {
		     	            'title':'提示',
		     	            'buttons':['确定']
		     	         }); 
						window.location.href="/examReport/take-xq2?paperId="+paperId;
					}
    		}
    	}); 
    }
    /*]]>*/  
</script>
</html>